$(function(){
	var sear = window.location.search
	var arr = sear.split('=');
	var id = arr[1];
	$.ajax({
		type:"post",
		url:url+'/mineral/itceth.html?token='+token,
		async:true,
		data:{'id':id,"token":token},
		dataType:'json',
		success:function(result){
			if(result.status==1){
				console.log(result);
				var data = result.data
				$("#model").val(data.model+'矿机');
				$("#valid").val(data.valid+' 天'); 
				$("#capacity").val(data.capacity+' GXA');
				$("#price").val((result.money*7).toFixed(2) +" CNY");
				$("#foo").val(result.address);
				console.log(result.address)
			}
			else if(result.status==2){
                location.href="gxa://logout";
			}else{
                isErr(result)
			}
		}
	})
})

function toPay(){
	$(".deorlink").prop("disabled",true);
	var sear = window.location.search
	var arr = sear.split('=');
	var id = arr[1];
	var fileObj = $("#fileInput")[0].files; 
	console.log(fileObj[0])
    var formData=new FormData();
		formData.append("WB_UserProfile[photo]",fileObj[0]); 
		formData.append("id",id); 
		formData.append("token",token); 
		$.ajax({
			type:"post",
			url:url+"/mineral/buyeth.html",
			async:true,
			data:formData,
//			cache: false,  
			processData: false,
			contentType: false,
			dataType:'json',
			success:function(result){
				$(".deorlink").prop("disabled",false);
				if(result.status==1){
					alert(result.message);
				}else if(result.status==2){
                    location.href="gxa://logout";
                }else{
                    isErr(result)
                }
			}
		});
}

var clipboard = new Clipboard('#deorilink');
clipboard.on('success', function(e) {
    var msg = e.trigger.getAttribute('aria-label');
    alert(msg);

    e.clearSelection();
});
clipboard.on('error', function(e) {
    // alert("请选择“拷贝”进行复制!")
    var str = $("#foo").val();
    isa(str);
});
     

//判断是否是安卓还是ios
function isAndroid_ios(){
    var u = navigator.userAgent, app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    return isAndroid==true?true:false;
}
function isa(str){
    if (isAndroid_ios()) {
        window.android.copyText(str);
    }else{
    	window.webkit.messageHandlers.yglCopy.postMessage({'str':str});
    }
}